Expose swift debug payload#283
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR exposes a “plaintext bridge payload” JSON builder for native SDKs (Swift and Kotlin) via UniFFI/Rust, enabling integrators to inspect and assert the bridge payload contract before encryption/upload—aligned with the bridgeDebugPayload* naming direction used in JS.
Changes:
- Rust/UniFFI: Add
IDKitBuilder.bridge_debug_payload_json*APIs that serialize the existing request payload builder output (without creating a bridge request and without a timestamp). - Swift & Kotlin: Add builder wrapper methods to surface the new UniFFI APIs (
bridgeDebugPayloadJSON/bridgeDebugPayloadJson, plus preset variants). - Tests: Add Swift and Kotlin tests asserting the identity-check preset payload includes key contract fields and omits
timestamp.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| swift/Tests/IDKitTests/IDKitTests.swift | Adds a Swift test validating the identity-check plaintext bridge payload JSON contract. |
| swift/Sources/IDKit/IDKit.swift | Exposes new Swift IDKitBuilder methods to fetch plaintext bridge payload JSON (constraints + preset). |
| scripts/package-swift.sh | Adjusts Swift XCFramework header/modulemap staging to use ios_build/Headers/ root. |
| rust/core/src/bridge.rs | Implements UniFFI-exposed Rust methods to build/serialize plaintext bridge payload JSON without creating a request. |
| kotlin/bindings/src/test/kotlin/com/worldcoin/idkit/IDKitTests.kt | Adds a Kotlin test validating the identity-check plaintext bridge payload JSON contract. |
| kotlin/bindings/src/main/kotlin/com/worldcoin/idkit/IdKit.kt | Exposes new Kotlin IDKitBuilder methods for plaintext bridge payload JSON (constraints + preset). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…wift gets typed structs instead of raw json added BridgeDebugPayload (and related records) in bridge.rs with parsing from the existing build_request_payload wire json, plus bridge_debug_payload ffi methods on IDKitBuilder. swift now exposes bridgeDebugPayload on IDKit/IDKitBuilder for property access in tests and app code. kept the json-returning helpers as a fallback for logging or if you need the raw wire string. updated swift tests to assert on typed fields instead of JSONSerialization.
…it into expose-swift-debug-payload
…it into expose-swift-debug-payload
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7beed69. Configure here.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d6bd916fc5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// wrong, or serialization fails. | ||
| pub fn build_request_payload( | ||
| /// Returns an error if constraints are invalid or the signature/nonce format is wrong. | ||
| fn build_request_payload( |
There was a problem hiding this comment.
Keep build_request_payload public
When Rust consumers build the plaintext bridge JSON directly through the public idkit_core::bridge::build_request_payload(...) helper, this change removes that symbol from the public bridge module and changes its return type to the private wire struct. Even though in-repo call sites were moved to build_request_payload_json, downstream integrations that use the existing helper will fail on upgrade; keep a public shim with the old Result<serde_json::Value> signature or deprecate it instead of making the rename source-breaking.
Useful? React with 👍 / 👎.
…y is exposed by ffi

Summary
We wanted to expose raw payload fields to Swift developers of IDKit. Moreover, we wanted to expose the fields as native swift structs to catch possible errors at compile time.
Fix
Added UniFFI records in bridge.rs that map from the existing build_request_payload wire JSON via parse helpers, plus new bridge_debug_payload methods on IDKitBuilder. Swift now exposes bridgeDebugPayload on IDKit and IDKitBuilder so devs can dot into fields like proofRequest.proofRequests instead of parsing dictionaries. Kept the JSON-returning helpers as a fallback for logging or if you need the raw wire string. Updated the swift test to assert on typed fields instead of JSONSerialization.
Note
Medium Risk
Touches bridge payload construction and FFI surface for proof-request fields, but the change is additive (debug/fixture APIs) and normal encrypted bridge flows still serialize the same wire JSON.
Overview
Adds a typed, network-free path to inspect the plaintext bridge request that IDKit would send, aimed at test fixtures and contract debugging on Swift and Kotlin (mirrored on both).
In Rust, payload construction now returns a
BridgeRequestPayloadstruct internally, withbuild_request_payload_jsonkept for wire serialization; UniFFI records/objects (BridgeRequestPayloadWrapper, nested proof/credential/constraint wrappers) map from that payload.IDKitBuildergainsbridge_request_payload/ JSON helpers for constraints and presets without opening a bridge connection.Swift and Kotlin expose
createBridgePayloadFromPresetsandcreateBridgePayloadFromConstraints, typealiases for the wrapper types, andcredentialIdentifiershelpers. Tests now assert on typed fields (identity check, passport-or-mnc constraints) instead of parsing JSON. WASMnativePayloadcall sites switch to the JSON builder; Swift packaging adjusts XCFramework header layout.Reviewed by Cursor Bugbot for commit dc064a7. Bugbot is set up for automated code reviews on this repo. Configure here.